package com.yangming.springboot.deepin.controller;

import com.yangming.springboot.deepin.service.UserService;
import com.yangming.springboot.deepin.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * @创建人 ym
 * @创建时间 2021/3/30 0030
 * @描述
 **/
@RestController
@RequestMapping(value = "user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "index")
    public String index(){
        return "user/index";
    }

    @GetMapping(value = "hello")
    public String helloSpring(){
        return "hello";
    }


    @RequestMapping(value = "queryUserById")
    @ResponseBody
    public User queryUserById(Integer id){
        return userService.queryUserById(id);
    }

    @RequestMapping(value = "new")
    @ResponseBody
    public ModelAndView create(ModelMap model){
        String[] file = {"/images/movie/xiyouji.jpg", "/images/movies/xiyoujixuji.jpg"};
        model.addAttribute("files", file);
        return new ModelAndView("movie/new");
    }

}
